<#
 #   It is recommended to test the script on a local machine for its purpose and effects. 
 #   ManageEngine Endpoint Central will not be responsible for any 
 #   damage/loss to the data/setup based on the behavior of the script.

 #   Description: Script is designed To Set the Queue name
 #   Configuration Type - COMPUTER
 #   Note: : The given queue name will set to the specified IP printer 
 #>

# Printer Name & Queue Name should be hardcoded here
$printerName = "PrinterName"
$queueName="QueueName"

$printer = Get-WmiObject -Class Win32_Printer -Filter "Name='$printerName'" | Select-Object -First 1

if ($printer) {
    Write-Host "printer  Found."
    $portname=$printer.PortName

    $printerport = Get-WmiObject -Class Win32_TCPIPPrinterPort -Filter "Name='$portname'" | Select-Object -First 1

    if ($printerport) {
           $printerport.Queue = $queueName
            $printerport.Put()
        Write-Host "Queue name set successfully."
    } else {
        Write-Host "Printerport not found."
    }
} else {
    Write-Host "Printer not found."
}